﻿using ServerCommon.Architecture;
using ServerCommon.Config;
using ServerCommon.Log;

namespace ChannelServer
{
    public class Program
    {
        public const string AppName = "ChannelServer";
        public const string Log4NetName = "/ChannelLog4net.xml";

        static void Main(string[] args)
        {
            string ConfigPath = CommandLineHelper.GetOption(args, 0, "../../../../../Configs");

            string logConfigFile = ConfigPath + Log4NetName;
            LogHelper.Init(logConfigFile, true, "./Log", AppName);




            //var builder = WebApplication.CreateBuilder(args);

            //// 配置 Kestrel
            //builder.WebHost.ConfigureKestrel(options =>
            //{
            //    // 监听特定的 IP 地址和端口
            //    options.ListenAnyIP(5000);
            //    options.ListenAnyIP(5001, listenOptions =>
            //    {
            //        listenOptions.Protocols = HttpProtocols.Http2;
            //    });
            //});

            //var app = builder.Build();

            //app.MapGet("/", () => "Hello, Kestrel!");

            //app.Run();


            ProgramChannelServer.Instance?.Init(ProgramServerType.Channel, AppName, ConfigPath);

            ProgramChannelServer.Instance?.Run();

            ProgramChannelServer.Instance?.Release();

            LogHelper.Release();
        }
    }
}
